<SCRIPT LANGUAGE="JavaScript" src="js/web_tree.js"></SCRIPT>
<script>
	with(document){ 
		write('<style>');
			write('TD.Tree_ChildNode_1{font-size:14px;font-style:normal;border:1pt solid white;padding-left:5px;padding-right:5px;}');
			write('TD.Tree_ChildNode_2{font-size:14px;font-style:normal;text-decoration:underline;color:#c96c45;border:1pt solid white;padding-left:5px;padding-right:5px;}');
			write('TD.Tree_ChildNode_3{font-size:14px;font-style:normal;color:#0000ff;border:1pt solid white;padding-left:5px;padding-right:5px;}');
			write('TD.Tree_ParentNode_1{font-size:14px;font-style:normal;border:1pt solid white;padding-left:5px;padding-right:5px;}');
			write('TD.Tree_ParentNode_2{font-size:14px;font-style:normal;background-color:#6d8dd8;border:1pt solid #000000;padding-left:5px;padding-right:5px;}');
			write('TD.Tree_ParentNode_3{font-size:14px;font-style:normal;background-color:#f0e68c;border:1pt solid #000000;padding-left:5px;padding-right:5px;}');
			write('</style>');
	} 
	var tree = new Tree_View();
	with (tree) 
	{ 
		style=style & (~ENUM_LINES_AT_ROOT); 
		childnode_class_normal='Tree_ChildNode_1'; 
		childnode_class_hover='Tree_ChildNode_2'; 
		childnode_class_selected='Tree_ChildNode_3'; 
		parentnode_class_normal='Tree_ParentNode_1'; 
		parentnode_class_hover='Tree_ParentNode_2'; 
		parentnode_class_selected='Tree_ParentNode_3'; 

		img_list.add('default_child','img/img_link.gif');
	} 

	var node = tree.add_root(TREE_LAST,"My Email");
	node.add_child(TREE_LAST,"Send");
	node = node.add_child(TREE_LAST,"Mail Box");
	node.add_child(TREE_LAST,"InBox");
	node.add_child(TREE_LAST,"Send");


	
	{% for greeting in greetings %}
		{% if greeting.author %}
		node.add_child(TREE_LAST,"({{greeting.author.nickname}}):{{ greeting.content }}");
		{% else %}
		node.add_child(TREE_LAST,"(Wawa):{{ greeting.content }}" );
		{% endif %}
	{% endfor %}


	node = tree.get_root();
	node.add_child(TREE_LAST,"Help");

	//handle keydown event
	tree.add_event('keydown','onkeydown');

	function onkeydown(Tree,node,hittest,event)
	{
		event.cancel();//canceled Default action of the event	
		if(event.keyCode == 40)//down
		{
			if(node)
			{
				if(node.first_child) 
				node.first_child.select();
				else if(node.next) 
				node.next.select();
				else if(node.parent.next)
				node.parent.next.select();
				else {
					var tmp=node;
					while(tmp.get_level()>1)
					{
						tmp=tmp.parent;
						if(tmp.next){
							break;
						}
					}
					if(tmp.next)tmp.next.select();
				}
			}
		}

		if(event.keyCode == 38)//up
		{
			if(node)
			{
				var tmp;
				if(node.prev) 
				{   
					tmp = node.prev;
					while(tmp.first_child){
						tmp=tmp.first_child;
						while(tmp.next)tmp=tmp.next;
					}			
					tmp.select();
				}
				else if(node.parent.get_level() >= 1)
				node.parent.select();
			}
		}

		if(event.keyCode == 13)//Enter
		{
			if(node) node.expand();
		}  
		if(event.keyCode == 46)
		{
			if(node)node.del();//delete node
		}
	}

</script>

    <form action="/memory/sign" method="post">
      <div><textarea name="content" rows="3" cols="60"></textarea></div>
      <div><input type="submit" value="Sign Guestbook"></div>
    </form>
